package com.dengyuanke.observerpattern.pushmodel;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体主题
 */
public class ConcreteSubject implements Subject{

private List<Observer> observers=null;

    public ConcreteSubject(){
        observers=new ArrayList<Observer>();
    }
    @Override
    public void attach(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyobserver(String msg) {
        for (Observer observer:observers) {
            observer.update(msg);
        }
    }
}
